package cn.tangsihai.feigin.clients;

import cn.tangsihai.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 降级工厂
 */
@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeginClient> {

    // 拖底类
    @Override
    public UserFeginClient create(Throwable throwable) {
        return new UserFeginClient() {
            @Override
            public User userGet(Long id) {
                throwable.printStackTrace();
                return new User(-1L, "用户服务异常");
            }
        };
    }
}
